cmake_minimum_required(VERSION 3.14)

project(libcli)

message("MINGW=${MINGW}")
message("CYGWIN=${CYGWIN}")
message("WIN32=${WIN32}")

MESSAGE(STATUS "operation system is ${CMAKE_SYSTEM}")

if (CMAKE_SYSTEM_NAME MATCHES "Linux")
	message(STATUS "current platform: Linux ")
	add_definitions("-w -g -c -D_LINUX_")
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
	message(STATUS "current platform: Windows")
	add_definitions("-w -g -c -DWIN32 -std=gnu++0x -DWIN32")
	if (MINGW)
		add_definitions("-DMINGW")
	endif()
	if (CYGWIN)
		add_definitions("-DCYGWIN")
	endif()
	set(EXTRA_DEFAULT_LIBS -lws2_32)
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
	message(STATUS "current platform: FreeBSD")
else ()
	message(STATUS "other platform: ${CMAKE_SYSTEM_NAME}")
endif (CMAKE_SYSTEM_NAME MATCHES "Linux")

message("CMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}")
message("CMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}")
message("CMAKE_SYSTEM=${CMAKE_SYSTEM}")

include_directories(
	"${CMAKE_CURRENT_SOURCE_DIR}/include/"
)
link_libraries(${EXTRA_DEFAULT_LIBS})
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib)

add_subdirectory(src)

if (BUILD_DEMO)
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib")
add_executable(cli_tester demo/main.cpp)
target_link_libraries(cli_tester cli)
endif()